package edu.whu.webgis.entity;


import edu.whu.webgis.utils.ImgUtil;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.Base64;

@Data
@NoArgsConstructor
public class VSimplePosting {
    Integer id;
    String pic;
    String content;
    String author;
    String title;
    Integer likes;

    public VSimplePosting(Posting posting) {
        this.id = posting.getId();
        this.content = posting.getContent();
        this.author = posting.getAuthor();
        this.title = posting.getTitle();
        this.likes = posting.getLikes();
        this.pic = ImgUtil.getBase64Jpg(posting.getPics().split(" ")[0]);
    }
}
